home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / pctv3n2.zip / MOUSEY.PAS < prev    next >
Pascal/Delphi Source File  |  1992-04-08  |  2KB  |  58 lines

  1. PROGRAM Mousey;   { Jim Kyle, 03-19-89; For Turbo Pascal 5.0    }
  2. {$M 2048,0,0}                { Limits Stack to 2K and Heap to 0 }
  3. USES Dos;
  4.  
  5. VAR
  6.   CmdPath   : ComStr;
  7.   CmdToDo   : ComStr;
  8.   I         : Integer;
  9.   Regs      : Registers;
  10.   Saved     : Boolean;
  11.   SavMse    : ARRAY[0..999] OF Byte;    { Need not be this big! }
  12.  
  13. PROCEDURE MseInt( N : Integer);
  14. BEGIN
  15.   Regs.es := Seg(SavMse);
  16.   Regs.dx := Ofs(SavMse);
  17.   Regs.ax := N;
  18.   Intr($33,Regs);
  19. END;
  20.  
  21. PROCEDURE SetMouse;              { Save the current mouse state }
  22. BEGIN
  23.   Regs.ax := $3533;
  24.   MsDos( Regs );
  25.   Saved := (Regs.es OR Regs.bx) <> 0;
  26.   IF Saved THEN BEGIN
  27.     MseInt(22);
  28.     WriteLn('Mouse Saved...');
  29.   END;
  30. END;
  31.  
  32. PROCEDURE ResetMouse;           { Restore previous mouse state }
  33. BEGIN
  34.   IF Saved THEN BEGIN
  35.     MseInt(23);
  36.     WriteLn('Mouse restored...');
  37.   END;
  38. END;
  39. {======================== Main Program =========================}
  40. BEGIN
  41.   IF ParamCount < 1 THEN BEGIN  { If no args, give help summary }
  42.     WriteLn( '  Usage: MOUSEY Command Parms' );
  43.     WriteLn( '  - Command is anything DOS will recognize');
  44.     WriteLn( '  - Parms can be whatever the command will accept');
  45.     Halt(255);
  46.   END;
  47.   SetMouse;            { Else install mouse service, saving old }
  48.   CmdToDo := '/C ';         { Build up command line from input }
  49.   FOR I := 1 TO ParamCount DO
  50.     CmdToDo := Concat(CmdToDo, ParamStr(i), ' ');
  51.   CmdPath := GetEnv( 'COMSPEC' );
  52.   SwapVectors;                           { Put back DOS vectors }
  53.   Exec(CmdPath, CmdToDo);              { Launch the application }
  54.   SwapVectors;                             { Restore TP vectors }
  55.   ResetMouse;                    { Restore original mouse setup }
  56.   Halt(DosExitCode);       { Return the application's exit code }
  57. END.
  58.